//
//  NewestDetailTableViewCell2.m
//  livingDesign
//
//  Created by dlios on 15-1-30.
//  Copyright (c) 2015年 怡居. All rights reserved.
//

#import "NewestDetailTableViewCell2.h"
#import "UIColor+AddColor.h"

@implementation NewestDetailTableViewCell2
- (void)dealloc
{
    [_detailLabel release];
    [super dealloc];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    self.detailLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.detailLabel];
        self.detailLabel.font = [UIFont systemFontOfSize:14];
//        self.detailLabel.textAlignment =  NSTextAlignmentLeft ;
//    self.detailLabel.backgroundColor = [UIColor colorFromHexCode:@"#abc88b"];
    self.detailLabel.numberOfLines = 0;
    [self.detailLabel release];
//    NSLog(@"d");
    }
    return self;
}

// set方法
- (void)setNewestDetail:(NewestDetail *)newestDetail
{
    _newestDetail = newestDetail;
//    NSLog(@"%@", self.newestDetail.block );
    [self showData];
}
- (void)showData
{
   
    if ([self.newestDetail.article isEqualToString:@""]||[self.newestDetail.article isEqualToString:@" "]) {
             self.detailLabel.text = self.newestDetail.title;
    }
    else
    {
        self.detailLabel.text = self.newestDetail.article;
    }
   

//    NSString *str = self.newestDetail.article
}


- (void)layoutSubviews
{
    [super layoutSubviews];
      NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:14]};
   CGRect rext = [self.detailLabel.text boundingRectWithSize:CGSizeMake(self.contentView.frame.size.width, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
//    NSLog(@"%@", self.detailLabel.text);
    self.detailLabel.frame = CGRectMake(20, 10, self.contentView.frame.size.width - 40, rext.size.height + 20);

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
